DirExists Function

public function DirExists(dir) result(exists)

returns TRUE if directory exists

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dir

Return Value logical


Source Code

FUNCTION DirExists &
!
(dir) &
!
RESULT (exists)

IMPLICIT NONE

!Arguments with intent(in):
CHARACTER (LEN = *), INTENT(IN) :: dir 

! Local declarations:  
LOGICAL                    :: exists
!------------end of declaration------------------------------------------------

!work around for cross compiler portability
#ifdef __INTEL_COMPILER
    !DIRECTORY specification is available only in intel compiler
    INQUIRE(DIRECTORY = dir, EXIST = exists)
#else
    !this solution does not work for intel compiler
    INQUIRE(FILE = dir // '/.', EXIST = exists)
#endif

RETURN
END	FUNCTION DirExists